<template>
	<view class="setting-container">
		<Nav :bgColor="bgColor" title="设置" @back="back"></Nav>
		<view class="list">
			<view class="list-item flex justify-between align-center" v-if="version">
				<text class="label">当前版本</text>
				<text class="value">{{version}}</text>
			</view>
			<navigator url="/pages/magic-box/rule/index?url=/api/protocal/platformhelp.html"
				class="list-item flex justify-between align-center">
				<text class="label">服务协议</text>
				<text class="iconfont1 arrow-right icon-jiantou1"></text>
			</navigator>
			<navigator url="/pages/magic-box/rule/index?url=/api/protocal/privacy.html"
				class="list-item flex justify-between align-center">
				<text class="label">隐私政策</text>
				<text class="iconfont1 arrow-right icon-jiantou1"></text>
			</navigator>
		</view>
		<view v-if="isLogin" class="logout iphone-x" @click="logout">退出登录</view>
	</view>
</template>

<script>
	import Nav from "@/components/magic-box/magic-nav/index.vue"
	import navMixin from "@/common/js/nav.js";
	import {
		getCurrentNo
	} from '@/js_sdk/APPUpdate/index';
	export default {
		mixins: [navMixin],
		components: {
			Nav
		},
		data() {
			return {
				version: ''
			};
		},
		computed: {
			isLogin() {
				return this.$store.state.isLogin || false;
			},
		},
		async onLoad() {
			// #ifdef APP-PLUS
			plus.runtime.getProperty(plus.runtime.appid, (inf) => {
				console.log(inf.versionCode);
				console.log(inf.version);
				let channel = 'default';
				const isAndroid = uni.getSystemInfoSync().platform == "android";
				if (isAndroid) {
					channel = plus.runtime.channel||'default';
				} else {
					channel = "ios";
				}
				this.version = `${inf.version}(${channel})`;
			});
			// #endif
		},
		methods: {
			// 退出登录
			logout() {
				uni.showModal({
					title: '提示',
					content: '确定要退出登录吗',
					success: (res) => {
						if (res.confirm) {
							uni.removeStorage({
								key: 'token',
								success: res => {
									uni.setStorageSync('loginLock', 1);
									//购物车数量
									uni.removeStorageSync('userInfo');
									uni.removeStorageSync('version');
									this.$store.dispatch('loginout');
									this.$store.dispatch('getCartNumber').then((e) => {})
									this.$util.redirectTo('/pages/member/index/index');
								}
							});
						}
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.setting-container {
		.list {
			padding: 0 21rpx 0 19rpx;
			background-color: #fff;

			.list-item {
				border-bottom: 1rpx solid #DADADA;
				height: 112rpx;

				&:last-child {
					border-bottom: none;
				}

				.label {
					font-size: 33rpx;
					color: #111111;
				}

				.value {
					font-size: 32rpx;
					color: #666666;
				}

				.arrow-right {
					font-size: 28rpx;
					color: #BFBFBF;
				}
			}
		}

		.logout {
			position: fixed;
			bottom: 0;
			width: 100%;
			left: 0;
			height: 111rpx;
			background: #FFFFFF;
			font-size: 33rpx;
			font-weight: 500;
			color: #111111;
			text-align: center;
			line-height: 111rpx;
		}
	}
</style>
